{% extends 'adminlte/base.html' %}
{% load staticfiles %}
{% if title %} 
    {% block title %}
        所有工单
    {% endblock %}
{% endif %}

{% block js %}
<!--
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>
-->

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script type="text/javascript" charset="utf8" src="{% static 'datatables/media/js/jquery.dataTables.min.js'%} "></script>
<script type="text/javascript" charset="utf8" src="{% static 'datatables/media/js/dataTables.bootstrap.min.js'%} "></script>

<script type="application/javascript">
	$(function () {
        
		$('#sample_3').DataTable({
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "iDisplayLength": 10,
            "autoWidth": false,
			/*
		///////////////////////////////////////
		 ajax: function (data, callback, settings) {
            console.log(data);
            var param = {};
            //param.per_page = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
            //param.page = (data.start / data.length)+1;//当前页码
            //param.search_value=data.search.value;
            param.per_page =10
			param.page = 1
			param.search_value = 'admin'
			console.log(param);    
           
			$.ajax({
              type: "GET",
              url: "http://www.ydyw.com:8008/workflow/all/",
              cache: false,  //禁用缓存
              data: param,  //传入组装的参数
              dataType: "json",
              success: function (result) {
                 var returnData = {};
                 returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                 returnData.recordsTotal = result.data.total;//返回数据全部记录
                 returnData.recordsFiltered = result.data.total;//后台不实现过滤功能，每次查询均视作全部结果
                 returnData.data = result.data.value;//返回的数据列表
                //console.log(returnData);
                //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕
        
                // 填充新增流转记录表单中可选的源和目标状态
                
				$("#sourceStateId").empty();
                $("#destinationStateId").empty();
                result.data.value.map(function(currentValue,index,arr){$("#sourceStateId").append("<option value=" + "'" + currentValue.id + "'" + ">" + currentValue.name + "</option>");})
                result.data.value.map(function(currentValue,index,arr){$("#destinationStateId").append("<option value=" + "'" + currentValue.id + "'" + ">" + currentValue.name + "</option>");})
                
				callback(returnData);
				
            },
                 
            })
            
		    console.log("数据")
    },
        ///////////////////////////////////////		
			*/
        });
       
		});
</script>
{% endblock %}

{% block css %}
<link rel="stylesheet" type="text/css" href="{% static 'datatables/media/css/dataTables.bootstrap.min.css' %}">
{% endblock %}

{% block head_ext %}
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        {{app_label}}
        <small>{{title|capfirst}}</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href=""><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">所有工单</li>
    </ol>
</section>
{{extra_content}}{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="box box-success">
                <div class="box-header with-border">
                    <div class="caption">
                        <!--<i class="fa fa-globe"></i> <h3 class="box-title">Visitors Report</h3>-->
                    </div>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                        </button>
                        <div class="btn-group">
                            <button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-wrench"></i></button>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="#">Action</a></li>
                                <li><a href="#">Another action</a></li>
                                <li><a href="#">Something else here</a></li>
                                <li class="divider"></li>
                                <li><a href="#">Separated link</a></li>
                            </ul>
                        </div>
                        <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                    </div>
                </div>
                <div class="box-body ">
                        <table class="table table-striped table-bordered table-hover dt-responsive" width="100%" id="sample_3" cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <th >流水号</th>
                            <th >标题</th>
                            <th >业务流程</th>
                            <th >当前状态</th>
                            <th >创建人</th>
                            <th >创建时间</th>
                            <th >更新时间</th>
                            <th >操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if ticket_result_restful_list %}
                            {% for ticket in ticket_result_restful_list %}
                        <tr>
                            <td>{{ticket.sn}}</td>
                            <td>{{ticket.title}}</td>
                            <td>{{ticket.workflow.workflow_name}}</td>
                            <td>{{ticket.state.state_name}}</td>
                            <td>{{ticket.creator}}</td>
                            <td>{{ticket.gmt_created}}</td>
                            <td>{{ticket.gmt_modified}}</td>
                            <td><a href="{% url 'ticketdetailtable' ticket.id %}">详情</a></td>
                        </tr>
                            {% endfor %}
                        {% endif %}
                        </tbody>
                        </table>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>

    </div>

{% endblock %}
